//
//  FocusControl.m
//  quanminzhekou
//
//  Created by zxl on 15/1/23.
//  Copyright (c) 2015年 zhongqinglongtu. All rights reserved.
//

#import "FocusControl.h"
#import "UIImageView+WebCache.h"

@implementation FocusControl
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        _imageView = [[UIImageView alloc] initWithFrame:self.bounds];
        _imageView.backgroundColor = [UIColor clearColor];
        _imageView.userInteractionEnabled = YES;
        [self addSubview:_imageView];
        
        _markCtrl = [[UIControl alloc] initWithFrame:self.bounds];
        _markCtrl.backgroundColor = [UIColor clearColor];
        [_markCtrl addTarget:self action:@selector(onTapMarkCtrl:) forControlEvents:UIControlEventTouchUpInside];
        [self addSubview:_markCtrl];
    }
    return self;
}

- (void)setViewModel:(FocusViewModel *)viewModel {
    _viewModel = viewModel;
    [self.imageView sd_setImageWithURL:viewModel.imageUrl placeholderImage:[UIImage imageNamed:@"common_banner_placeholder"]];
}

#pragma mark - 
- (void)onTapMarkCtrl:(UIControl*)ctrl {
    if (self.tapControlHandler) {
        self.tapControlHandler(self.viewModel);
    }
}

@end
